package 指数H3;

import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        PriorityQueue<Integer> heap = new PriorityQueue<>();
        for (int i = 1; i <= T; i++) {
            heap.clear();
            System.out.printf("Case #%d: ", i);
            int n = in.nextInt();
            int res = 0;
            while (n-- > 0) {
                int x = in.nextInt();
                if (x > res) {
                    heap.offer(x);
                }
                while (!heap.isEmpty() && heap.peek() == res) {
                    heap.poll();
                }
                if (heap.size() > res) {
                    res++;
                }
                System.out.print(res + " ");
            }
            System.out.println();
        }
    }
}
